﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class Solution141
{
    public bool HasCycle(ListNode head)
    {


        if (head == null)
        {
            return false;
        }
        ListNode low = head;

        ListNode fast = head;

        while (fast != null && fast.next != null)
        {


            low = low.next;
            fast = fast.next.next;
            if (fast == low)
            {
                return true;
            }
        }
        return false;

    }
}

class Program141
{
    static void Main141(string[] args)
    {
        ListNode head=new ListNode(1);
        ListNode next=new ListNode(2);
        head.next = next;

        Solution141 solution = new Solution141();
      bool res=  solution.HasCycle(head);
        Console.WriteLine(res);

    }
}